package repository;

import java.util.ArrayList;
import java.util.List;

public class WalletRepository {

    private WalletEntity walletEntity = new WalletEntity(0);
    private WalletEntity walletEntity1 = new WalletEntity(1,100);
    private WalletEntity walletEntity2 = new WalletEntity(2,200);

    public WalletEntity getWalletEntity(int walletId) {
        if(walletId == 1){return walletEntity1;}
        else if(walletId == 2){return walletEntity2;}
        else if(walletId == 0){return walletEntity;}
        else {return new WalletEntity(walletId);}
    }
    public double getBalance(int walletId) {
        return getWalletEntity(walletId).getBalance();
    }
    public List<String> getFlows(int walletId) {
        return getWalletEntity(walletId).getFlows();
    }
    public void updateBalance(int walletId, double newBalance){
        getWalletEntity(walletId).setBalance(newBalance);
    }
    public void freezeBalance(int walletId, double newBalance, double freezeBalance){
        getWalletEntity(walletId).setBalance(newBalance);
        freezeBalance += getWalletEntity(walletId).getFreezeBalance();
        getWalletEntity(walletId).setFreezeBalance(freezeBalance);
    }
    public void canOverdraft(int walletId, double limit){
        getWalletEntity(walletId).setCanOverdraft(true);
        getWalletEntity(walletId).setOverdraftLimit(limit);
    }
    public void canNotOverdraft(int walletId){
        getWalletEntity(walletId).setCanOverdraft(false);
    }
    public double getOverdraftLimit(int walletId){
        return getWalletEntity(walletId).getOverdraftLimit();
    }
    public boolean getCanOverdraft(int walletId){
        return getWalletEntity(walletId).getCanOverdraft();
    }
    public void addFlows(int walletId, String flow) {
        getWalletEntity(walletId).addFlows(flow);
    }
}

